import { getObj } from '@/views/wy-lessor/landlord/api/lessor'
import { fetchList } from '@/views/wy-lessor/landlord/api/lessorlinkinfo'
import uploadMedia from '@/components/upload-media.vue'
import contractInfoRent from '@/views/wy-lessor/landlord/components/contract-info-rent.vue'
import paymentrecord from '@/views/wy-lessor/landlord/components/payment-record.vue'
import { mapState } from "vuex";

export default {
    name: 'look',
    computed: {
        ...mapState({
            lessee_type: state => {
                let data = state.dict.find(item => item.type === "lessee_type") || {}
                let list = data.children || []
                return data.children || []
            },
        }),
    },
    components: {
        uploadMedia,
        contractInfoRent,
        paymentrecord,
    },
    created () {
        const loading = this.$loading({
            lock: true,
            text: '数据加载中'
        });
        //qh+:获取路径上传过来的ID
        this.lessorId = this.$route.query.id


        //通过id获取项目信息
        getObj(this.lessorId).then(rep => {
            this.propForm = rep.data.data
            if (this.propForm.lessorType == 0) {
                this.clientLesseeTypeMean = '个人'
            } else if (this.propForm.lessorType == 1) {
                this.clientLesseeTypeMean = '企业'
            } else if (this.propForm.lessorType == 2) {
                this.clientLesseeTypeMean = '个体户'
            } else if (this.propForm.lessorType == 3) {
                this.clientLesseeTypeMean = '政府机构'
            } else if (this.propForm.lessorType == 4) {
                this.clientLesseeTypeMean = '国有企业'
            }
            if (this.propForm.lessorType == 0) {
                if (this.propForm.certificateType == 0) {
                    this.certificateTypeMean = "身份证"
                } else if (this.propForm.certificateType == 1) {
                    this.certificateTypeMean = "军官证"
                } else if (this.propForm.certificateType == 2) {
                    this.certificateTypeMean = "港澳台身份证"
                } else if (this.propForm.certificateType == 3) {
                    this.certificateTypeMean = "华侨身份证"
                } else if (this.propForm.certificateType == 4) {
                    this.certificateTypeMean = "外籍护照"
                }
            } else {
                if (this.propForm.certificateType == 0) {
                    this.certificateTypeMean = "营业执照"
                } else if (this.propForm.certificateType == 1) {
                    this.certificateTypeMean = "组织机构代码证"
                } else if (this.propForm.certificateType == 2) {
                    this.certificateTypeMean = "社会信用码"
                } else if (this.propForm.certificateType == 3) {
                    this.certificateTypeMean = "税务登记号"
                } else if (this.propForm.certificateType == 4) {
                    this.certificateTypeMean = "其他"
                }
            }
            console.log(this.clientLesseeTypeMean)

            loading.close()
        }).catch(e => {
            loading.close()
            this.$message({
                type: 'error',
                message: '数据获取失败!'
            })
        })
        this.busId = this.$route.query.id

        this.queryLinkInfo(this.lessorId);
    },
    mounted () {
        this.$refs.lesseeUpload.getFiles(this.busId)
    },
    data () {
        return {
            lessorId: '',
            streets: [],
            propForm: {
                lessorName: '',
                lessorType: '',
                certificateType: '',
                certificateNum: '',
                categroyEmployment: '',
                primaryBusiness: '',
                legalPerson: '',
                legalIdentityCard: '',
                telephone: '',
                scopeBusiness: '',
                address: '',
                providerPrincipal: '',
                phoneNum: '',
                email: '',
                remarks: ''
            },
            clientLesseeTypeMean: '',
            certificateType: '',
            linkInfo: [],
            searchForm: {},
            modelType: 'client-manage',
            busId: '',
            activeName: 'first',
            //合同信息
            contractData: [],
            projectData: [],
        }
    },
    methods: {
        queryItem (val) {

        },
        queryLinkInfo (val) {
            this.searchForm.lessorId = this.lessorId;
            fetchList(Object.assign({}, this.searchForm)).then(response => {
                console.log(response.data.data)
                this.linkInfo = response.data.data
                console.log(this.linkInfo)
            }).catch(() => {
                console.log("catch")
            })
        },
        closeTab () {
            //关闭当前新增页，暂时没找到好办法
            // this.$store.commit("delHistoryRoute", this.$route.fullPath);
            // this.$parent.$children[2].closeTab('current')
            //跳转
            //this.$router.push("/property-info-sys/project-manage");
        },
        getClientProviderTypeMean () {
            var typeVal;
            if (this.propForm.lessorType == 0) {
                typeVal = '个人'
            } else if (this.propForm.lessorType == 1) {
                typeVal = '企业'
            } else if (this.propForm.lessorType == 2) {
                typeVal = this.lessee_type[2].label
            } else if (this.propForm.lessorType == 3) {
                typeVal = this.lessee_type[3].label
            } else if (this.propForm.lessorType == 4) {
                typeVal = this.lessee_type[4].label
            }
            return typeVal;
        },
        getCertificateTypeMean (val) {
            var type = this.propForm.lessorType
            if (type == 0) {
                if (val == 0) {
                    return "身份证"
                } else if (val == 1) {
                    return "军官证"
                } else if (val == 2) {
                    return "港澳台身份证件"
                } else if (val == 3) {
                    return "华侨身份郑"
                } else if (val == 4) {
                    return "外籍护照"
                }
            } else {
                if (val == 0) {
                    return "营业执照"
                } else if (val == 1) {
                    return "组织机构代码证"
                } else if (val == 2) {
                    return "社会信用码"
                } else if (val == 3) {
                    return "税务扥记号"
                } else if (val == 4) {
                    return "其他"
                }
            }
        },
        searchByKey () { },
        searchReset () { },
        selectionChange () { },
        changePageSize () { },
        changeCurrentPage () { },
        getListData () { }
    }

}
